package cn.kgc.springcloud.web.response;

import lombok.Data;

/**
 * @author 课工场
 * @date 2024/7/30
 * @description
 */
@Data
public class ResponseResult {

    private Integer code;
    private String message;
    private Object data;


    private ResponseResult(){}

    public static ResponseResult  success(){
        ResponseResult responseResult = new ResponseResult();
        responseResult.setCode(0);
        responseResult.setMessage("操作成功");
        return  responseResult;
    }

    public static ResponseResult  fail(){
        ResponseResult responseResult = new ResponseResult();
        responseResult.setCode(110);
        responseResult.setMessage("操作失败");

        return  responseResult;
    }

    public static ResponseResult  error(){
        ResponseResult responseResult = new ResponseResult();
        responseResult.setCode(500);
        responseResult.setMessage("服务器异常!!!");
        return  responseResult;
    }


    public ResponseResult  message(String message){
        this.message  = message;
        return  this;
    }

    public ResponseResult  data(Object data){
        this.data  = data;
        return  this;
    }
}
